Get Cell Comment value (Excel help needed)

Hello,

I believe I have the correct syntax to set the Cell "Comment" field but I can't seem to get the correct syntax to get the value back from excel; any help would be appreciated. Thank you.

void SetExcelCell(int        xCellLoc,
                  int        yCellLoc,
                      string     property,
                                  string     id,
                                  string     value)
{
        OleAutoObj objRange = excelSelectRangeByCoordinatesOLE( objExcelDataExportSheet, xCellLoc, yCellLoc )
        oleResult( olePut( objRange, property, value ) )

        clear ( autoArgs ) 
        put( autoArgs, "Text", id )
        oleResult( oleMethod( objRange, "AddComment", autoArgs ) )

        oleCloseAutoObject objRange
}

 


EHcnck - Wed Oct 15 15:26:25 EDT 2014

Re: Get Cell Comment value (Excel help needed)
tlhIngan - Fri Oct 17 14:38:57 EDT 2014

Here is a sample that works with excel 2007. Open an excel application and add your comment text to cell "A1" this little program will retrieve the comment and display it in the DXL output window.

OleAutoObj objExcel = null
OleAutoObj objWorkbooks = null
OleAutoObj objWorkbook = null
OleAutoObj objSheet = null
OleAutoObj objRange = null
OleAutoObj objComment = null
OleAutoArgs args   = create
string s
string m =""
objExcel = oleGetAutoObject("excel.application")
oleGet(objExcel,"ActiveWorkbook",objWorkbook)
oleGet(objWorkbook,"ActiveSheet",objSheet)
clear args
put(args,"A1")
oleGet(objSheet,"Range",args, objRange)

m = oleGet(objRange, "Comment",objComment)
if(null(objComment)){
    print "Bummer, objComment is null"
}
if (m!="") print m "\n"

clear args
m = oleMethod(objComment,"TEXT",args, s)
if (m!="") print m "\n"
print s